Previous Book Contents Next

Inside Macintosh: Using JBindery


Packaging a Java Application

Packaging a Java application to run under the Mac OS creates a file that contains the following items:

The packaged Java application does not contain the Java virtual machine. The host computer that executes the Java application must supply the virtual machine through the MRJ libraries.

For example, if you wanted to package the HelloWorld sample application using JBindery, you can do the following:

  1. Drag the class file HelloWorld.class onto the JBindery icon. JBindery launches, and HelloWorld is listed as the class name in the Command panel.
  2. Choose Save Settings... from any of the panels. When the save dialog box appears, name the file HelloWorld App and save it. Make sure the Save as Application checkbox is checked.

The resulting file HelloWorld App is the packaged Java application. You can double-click on the icon to launch it.

To create a more sophisticated packaged application using a virtual file system, you should observe the following steps:

  1. Put all the files your Java application requires into a single folder hierarchy. This folder should not contain any Mac OS resource files.
  2. Drag the class file, .zip package, or .jar package containing the application's main method onto the JBindery icon. Alternatively, you can launch JBindery and then enter the class name manually in the Command panel.
  3. In the Command panel, enter any parameters your application requires and choose paths for console output and input.
  4. In the Properties panel, enter any property/value pairs you want to include with your application.
  5. In the Appearance panel, select any desired appearance features.
  6. In the Security panel, specify any proxy servers, if desired, and choose whether you want to use the code verifier.
  7. In the Application panel, choose a signature (also called a creator) for your application. If you plan to distribute your application (whether commercially or as shareware), you should register the creator with Apple. The default creator is '????' . See The Application Panel for more information.
  8. If desired, you can change the default application heap sizes in the Application panel.
  9. If you have any Mac OS resources you want to include, drag the compiled resource file onto the Merge Resources From box in the Application panel (or click on the box to select the resource file manually). See Mac OS Resources for more information about resources.
  10. If the folder containing your Java application's class files (that is, the top-level folder of your folder hierarchy) does not already appear in the Classpath panel, drag the folder onto the class path list (or click on the Add Folder button to choose the folder using a dialog box).
  11. In the class path list, select the folder containing your application's class files and click on the Make VFS button. Doing so designates your folder as the virtual file system. Delete all other entries in the class path list.
  12. If you did not choose to expand the .zip or .jar files in your folder hierarchy, you must add paths to each such file by selecting the Add Manually button in the Classpath panel. For example, if you had the file cookie.jar in the top level of the folder hierarchy, you must add the path file:///$VFS/cookie.jar .
  13. If the folder containing your Java application's class files contains any .jar files (expanded or not) and you are running JBindery under MRJ 2.0, you must add class paths to the .jar files using the Add Manually button (as in step 12.).
  14. Choose Save Settings... from any of the panels. When the save dialog box appears, choose a name for your packaged Java application file.
  15. Select the Save as Application checkbox in the save dialog box and save your packaged file.

During the save process, JBindery displays some progress information as it packages the files you specified in the Virtual File System panel. The saved file can now be launched like a Mac OS application. Alternatively, if you select the Run button while still in JBindery, JBindery automatically quits and launches your packaged application.

If desired, you can keep the Java application class files separate from the application file by not selecting a virtual file system. The resulting application file then contains only the following items:

To build a packaged application with separate class files, you should do the following:

  1. Follow steps 2 through 8 as for creating an application with packaged class files.
  2. In the Classpath panel, enter any additional paths you want searched when looking for the Java application's class files. Note that paths stored as aliases may not be resolvable if the application is moved to a different computer.
  3. Choose Save Settings... from any of the panels. When the save dialog box appears, choose a name for your application file.
  4. Select the Save as Application checkbox in the save dialog box and save your packaged file.

The resulting application file can be launched like a Mac OS application assuming that the required Java classes can be found.


Previous Book Contents Next

© Apple Computer, Inc.
06 AUGUST 1998